import https from '@/utils/https';
import { ContentType, Method } from 'axios-mapper';

export interface LoginResult {
  access_token: string;
  token_type: string;
  refresh_token: string;
  expires_in: number;
  scope: string;
  user_name: string;
  uNITID: string;
  avatar: string;
  client_id: string;
  role_name: string;
  license: string;
  user_id: string;
  fzzjg: string;
  role_id: string;
  f_ZGHB: string;
  imUserId: string;
  imUserPassword: string;
  dept_id: string;
  jti: string;
}

export function login(username: string, password: string) {
  return https.request<LoginResult>(
    'auth/blade-auth/oauth/token',
    Method.POST,
    { username, password, grant_type: 'captcha' },
    ContentType.form,
  );
}
